package com.spring.annotation;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class MainConfigTest {

	@Test
	public void testShow() {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainConfig.class);
		
		Book book = (Book) context.getBean(Book.class);
		book.add();
	}
	
	@Test
	public void testAppConfig() {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		
		Book book = (Book) context.getBean(Book.class);
		book.add();
	}
	
	@Test
	public void testDatabaseConfig() {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(DatabaseConfig.class);
		
		OracleBean bean = context.getBean(OracleBean.class);
		
		bean.getConnection();
	}
	
	@Test
	public void testFruitService() {
		ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		
		FruitService fruitService = (FruitService) context.getBean("fruitService");
		
		System.out.println(fruitService.hello());
	}
	
	

}
